function Session(a, b) {
    if (b === undefined) {
        this.key = a.key;
        this.list = a.list;
    } else {
        this.key = a; // 保存Session的时间
        this.list = eval(b); // 上次未关闭网页
    }

    // 直接套用app.js里面的buildList()函数
    this.BuildList = function() {
        var str = '';
        var data = this.list;
        for (var i = 0; i < data.length; i++) {
            if (data[i].reopend) {
                continue;
            }
            str += String.format(CONST.STR_LIST, i, encodeHtml(data[i].url),
                    encodeHtml(data[i].title));
        }
        return str;
    };

    /*
     * 清除已经打开过的链接（reopend=true的链接） 可以节省一些不必要的空间，避免链接列表过大
     */
    this.ClearOpenedLinks = function() {
        this.list = this.list.filter(function(element) {
            return !element.reopend;
        });
    };

    this.SaveAsFile = function() {
        var content = JSON.stringify(this);
        var blob = new Blob([ content ], {
            type : "text/plain;charset=utf-8"
        });
        saveAs(blob, this.key + '.txt');
    };

    this.toString = function() {
        return JSON.stringify(this.list);
    };

    this.count = function() {
        return this.list.length;
    };
}
